package com.iss.demo.dao;

import com.iss.demo.entity.fourCourse;
import com.iss.demo.model.fourCourseModel;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface fourCourseDao {


        @Select("select * from fourcourse ")
        List<fourCourseModel> selectAll();


        @Delete(" <script>"+"delete from fourcourse where f_id in" +
                "    <foreach collection=\"array\" item=\"id\" separator=\",\" open=\"(\" close=\")\">" +
                "        #{id}" +
                "    </foreach></script>")
        public Integer delete(Integer[] f_ids);
//    @Delete("delete from fourcourse where f_id=#{f_id}")
//    public Integer deleteOne(Integer f_id);

        @Insert("insert into fourcourse values(null,#{f_name},#{f_time},#{f_price},#{f_des},2,null,null)")
        public Integer insertCourse(fourCourse fourcourse);

        @Update("update fourcourse set f_name=#{f_name},f_time=#{f_time},f_price=#{f_price},f_des=#{f_des} where f_id=#{f_id}")
        public Integer updateCourse(fourCourse fourcourse);

        @Select("select * from fourcourse where f_id=#{f_id}")
        public fourCourse selectByid(Integer id);

        @Update("update fourcourse set f_surface = #{surface},f_info = #{info} where f_id=#{id}")
        public Integer updateInfo(@Param("surface") String surface,@Param("info") String info,@Param("id") Integer id);

        @Select("select f_name,f_price from fourcourse where f_id=#{f_id}")
        public fourCourse shopcar(Integer id);
    }